package model;

/**
 * @author Beth Katz
 *
 */
public class PuzzleCell {
	private char data;
	private boolean used;
	private final char FILLCHARACTER = '!';
	private static PuzzleCell borderCell = null;


	/**
	 * @param cell's character
	 */
	public PuzzleCell(char ch) {
		data = ch;
		used = false;
	}

	/**
	 * uses FILLCHARACTER as default
	 */
	public PuzzleCell( ) {
		data = FILLCHARACTER;
		used = false;
	}

	/**
	 * @return the data
	 */
	public char getData() {
		return data;
	}

	/**
	 * @param the new value for data
	 */
	public void setData(char ch) {
		data = ch;
		used = false;
	}

	/**
	 * @return whether or not cell is used
	 */
	public boolean isUsed() {
		return used;
	}

	/**
	 * @param value for used
	 */
	public void setUsed(boolean flag) {
		used = flag;
	}

	/**
	 * @return the shared border cell 
	 */
	public static PuzzleCell sharedBorderCell( ) {
		if (borderCell == null) {
			borderCell = new PuzzleCell( );
		}
		return borderCell;
	}

	/**
	 * provides the string version of the cell
	 * @return string containing cell's character
	 */
	public String ToString( ) {
		char ch = data;
		if (used) {
			ch = Character.toUpperCase(ch); 
		}
		return ("" + ch);
	}
}
